package com.shushan.pages.newtype.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: StrangeWordsStudyItemBean
 * @Desciption: //生字学一学每一题数据bean
 * @author: zhangshihao
 * @date: 2018-07-23
 */
public class StrangeWordsStudyItemBean extends NetBaseBean {

    public int id;
    public String name;
    public String pinyin;
    public String voice;
    public String voice_time;
    public String gif_url;

    private List<StrangeWordsPhraseItemBean> phraseItemBeanList = new ArrayList<>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        id = jsonObject.optInt("id",0);
        name = jsonObject.optString("name","");
        pinyin = jsonObject.optString("pinyin","");
        voice = jsonObject.optString("voice","");
        voice_time = jsonObject.optString("voice_time","");
        gif_url = jsonObject.optString("gif_url","");

        JSONArray phraseArr = jsonObject.optJSONArray("phrase");
        if(phraseArr == null || phraseArr.length() == 0){
            return;
        }
        for(int i=0;i<phraseArr.length();i++){
            JSONObject obj = phraseArr.optJSONObject(i);
            StrangeWordsPhraseItemBean bean = new StrangeWordsPhraseItemBean();
            bean.initByJson(obj);
            phraseItemBeanList.add(bean);
        }
    }

    public List<StrangeWordsPhraseItemBean> getPhraseItemBeanList() {
        return phraseItemBeanList;
    }

}
